#pragma once
#include "gamePhase.h"
#include "game.h"
class ActionSelectionPhase: public GamePhase
{
private:
	Game * g;	//A pointer to the game object
	int cursorX, cursorY, prevX, prevY;
	char cursorIcon;
public:
	ActionSelectionPhase(Game * a_game)
	{
		g = a_game;
		cursorX = 0;
		cursorY = 0;
		prevX = 0;
		prevY = 0;
		cursorIcon = '*';
	}

	void update(int a_ms)
	{
		g->getCursorXY(cursorX, cursorY);
		switch(returnInput())
		{
		case 'w': case 'W': cursorY--; break;
		case 's': case 'S': cursorY++; break;
		case 'a': case 'A': cursorX-=15; break;
		case 'd': case 'D': cursorX+=15; break;
		}
		getInput(0);

		if (cursorY >= MAX_PLAYERS || cursorY < 0 || cursorX < 0 || cursorX > 31)	//Boundary checking
		{
			cursorX = prevX; cursorY = prevY;
		}
	}
	void draw()
	{
		for (int i = 0; i < MAX_PLAYERS; ++i)
		{
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY| i+1);
			g->getPlayers()[i].draw(i);
			printf("\n");
		}
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), WHITE);
		gotoxy(1, 10);
		printf("BangBangBang   Bang           Click");
		gotoxy(0,cursorY);
		putchar(cursorIcon);
		gotoxy(cursorX, 10);
		putchar(cursorIcon);
	}

	void undraw()
	{

	}
};